package com.javaweb.dao.impl;

import com.javaweb.dao.CategoryDao;
import com.javaweb.model.Category;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class CategoryDaoImpl implements CategoryDao {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Override
    public int insert(Category category) {
        String sql = "INSERT INTO tb_category (name, create_time) VALUES (?, ?)";
        int result = jdbcTemplate.update(sql, category.getName(), category.getCreateTime());
        return result == 1 ? 1 : 0; // 插入成功返回1，失败返回0
    }
}
